home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************
- "about.c"
-
- by Joe Pillera [MacTutor, January 1990]
-
- using Symantec's "THINK C", v 5.00
- *********************************************************/
-
-
- #include <string.h>
- #include <Traps.h>
-
- #include "protos"
-
- #include "globals.h"
- #include "extern.h"
-
- #include "about.h"
- #include "floatingWindow.h"
-
-
-
-
- HelpInfoHdl hHTBL;
- ListHandle my_List_Handle;
- Rect List_Rect, Display_Rect, Scroller_Rect;
- Rect Dest_Rect, View_Rect, Frame_Rect;
- short Current_Topic;
- short Current_Pict;
- DialogPtr helpPtr;
- TEHandle myTEHandle;
- Handle myTextHandle;
- ViewMode Last_Type;
- ControlHandle hScrollBar;
- short First_Menu, Last_Menu;
- short START, FINISH, lastHit;
- HelpTopic topics[MAX_TOPICS];
- /*
- ViewMode screen_mode[MAX_TOPICS];
- short resource_start[MAX_TOPICS];
- short resource_end[MAX_TOPICS];
- Str255 topic_name[MAX_TOPICS];
- */
- Boolean newStyleTE, newStyle;
- Handle myStylHandle;
- short halfPagePix, currentTopLine, halfPageTopLine, maxTopLine;
- Cell lastCell;
- short pageCells;
-
-
-
-
- void H_Add_List_String (ListHandle theList, Str255 theString) {
- /* Made this hummer general enough to accomodate multiple columns.
- ** Fill one complete row first before going onto another. */
-
- short theRow /* The row to add */, nCols;
- static Cell theCell = {0,0};
- Boolean newRow;
-
-
- if (theList == nil) return;
-
- nCols = (**theList).dataBounds.right - 1; /* Zero-based */
- if (theCell.h > nCols) theCell.h = 0;
-
- newRow = (theCell.h == 0);
- if (newRow) {
- theRow = LAddRow(1, 32000, theList);
- theCell.v = theRow;
- }
-
- LSetCell(theString + 1, theString[0], theCell, theList);
- /* H_Refresh_Topics draws by calling LUpdate: */
- // LDraw(theCell, theList);
-
- theCell.h++; // ... for NEXT time through.
-
- } /* H_Add_List_String */
-
-
-
- void Create_Help (void) {
-
- short DType; /* Item type. */
- Point cSize;
- Rect viewRect;
- Rect dataBounds;
- short defaultProcID = 0, htAdjust, viewHt;
- Handle DItem;
- short index;
- short bType; /* ... for Next/Previous Buttons: */
- Handle bHandle;
- Rect bBox;
- PenState pnState;
- FontInfo helpFont;
- Cell firstCell = {0,0};
-
-
- // Setup pointers to the intro screen:
- Current_Topic = START; /* = Initial_Picture from Init_Help(). */
- Current_Pict = topics[Current_Topic].resource_start;
-
- // Bring up the HELP screen:
- helpPtr = GetNewDialog(Help_Window, nil, (WindowPtr)-1);
- SetPort(helpPtr);
- // FrameDefaultButton(helpPtr); -- called within H_Handle_Update()
-
- /* // Hide Next & Previous Buttons for Intro Screen: -- H_Display_Pict does this !!
- GetDItem(helpPtr, Next_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
- GetDItem(helpPtr, Prev_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
-
- // Disable Next & Previous Buttons: -- H_Handle_List_Event does this !!
- H_Set_Button_State(Next_Button, false);
- H_Set_Button_State(Prev_Button, false); */
-
- // Now ... build the list:
- GetDItem(helpPtr, Topics_Area, &DType, &DItem, &List_Rect);
-
- /* Compute list area (a user-item) by
- subtracting space for the Scroll Bar(s): */
- viewRect = List_Rect;
- viewRect.right = viewRect.right + frame - scrollWidth;
- viewRect.bottom = viewRect.bottom + frame - scrollHeight;
-
- SetRect(&dataBounds, 0, 0, 1, 0); /* one column list */
-
- GetPenState(&pnState);
- ;
- cSize.h = viewRect.right - viewRect.left;
- PenNormal();
- TextFont(geneva);
- TextSize(10);
- GetFontInfo(&helpFont);
- cSize.v = helpFont.ascent + helpFont.descent + helpFont.leading;
-
- // Adjust heights of rView & overall List_Rect to be a multiple of cSize.v:
-
- viewHt = viewRect.bottom - viewRect.top;
- htAdjust = viewHt % cSize.v;
- viewRect.bottom = viewRect.bottom - htAdjust;
- List_Rect.bottom = List_Rect.bottom - htAdjust;
-
- // Redo the two rects in the gDynamicBalloons[] array just in case:
- gDynamicBalloons[(Topics_Area - 1)*2 + 1].dynamicR = List_Rect;
- gDynamicBalloons[(Topics_Area - 1)*2 + 2].dynamicR = List_Rect;
-
- // Make the list:
- my_List_Handle = LNew(&viewRect, // rView
- &dataBounds,
- cSize,
- defaultProcID,
- helpPtr, // the window
- true, // draw it
- true, // has Grow Box < NON-functional >
- true, // horizontal ScrollBar
- true); // vertical ScrollBar
- (*my_List_Handle)->selFlags = lOnlyOne + lNoNilHilite;
- (*my_List_Handle)->refCon = (long) true; /* has Grow Box */
- ;
- SetPenState(&pnState);
-
- // Fill in the initial list contents ~~ begin after the Intro PICT:
- for (index = START + 1; index <= FINISH; index++)
- H_Add_List_String(my_List_Handle, topics[index].topic_name);
- ;
- // LSetSelect(true, firstCell, my_List_Handle); -- Nope, let user do it !!
- SetPt(&lastCell,
- (**my_List_Handle).dataBounds.right - 1, // Cell # is one less.
- (**my_List_Handle).dataBounds.bottom - 1);
- pageCells = viewHt / cSize.v;
-
- LDoDraw(true, my_List_Handle);
-
- // Compute critical info once & for all:
- GetDItem(helpPtr, Display_Area, &DType, &DItem, &Display_Rect);
-
- Scroller_Rect = Display_Rect;
- Scroller_Rect.left = Scroller_Rect.right - scrollWidth;
-
- Frame_Rect = Display_Rect;
- Frame_Rect.right = Frame_Rect.right + frame - growBoxSize;
-
- View_Rect = Frame_Rect;
- InsetRect(&View_Rect, 4, 4);
- halfPagePix = (View_Rect.bottom - View_Rect.top) >> 1;
-
- Dest_Rect = View_Rect;
- Dest_Rect.bottom = 10000;
-
- // Wait till last to show window so that we don't see
- // cell-after-cell being drawn. H_Display_Pict sets up
- // the showing/hiding of the Previous/Next Buttons:
- H_Display_Pict(Current_Pict); /* Sets Last_Type = pict. */
- TShowWindow(helpPtr);
-
- /* Remember ... we can close the daggum thing ... ARRGH !!! */
- lastHit = -1;
-
- } /* Create_Help */
-
-
-
- void H_Dialog_String (DialogPtr dlg, short theItem, Str255 theString) {
-
- short iType;
- Handle iHandle;
- Rect iBox;
-
-
- GetDItem(dlg, theItem, &iType, &iHandle, &iBox);
- SetIText(iHandle, theString);
-
- } /* H_Dialog_String */
-
-
-
- void H_Display_Pict (short thisPict) {
-
- PicHandle thePict;
- short bType, pType;
- Handle bHandle, pHandle;
- Rect bBox, pBox, pictRect;
- PicHandle newPict;
- RgnHandle oldClip;
- short mesg_this_one; /* Screen we're on now. */
- short mesg_max_one; /* Total # of screens in HelpTopic. */
- Str255 s1, s2, s3, s4, s5;
-
-
- if (Last_Type == pict) {
- thePict = GetPicture(Current_Pict);
- if (thePict != nil) ReleaseResource(thePict);
- }
- else if (Last_Type == text) {
- if (newStyle) {
- HUnlock(myStylHandle);
- ReleaseResource(myStylHandle);
- }
- HUnlock(myTextHandle);
- ReleaseResource(myTextHandle);
- DisposeControl(hScrollBar);
- HUnlock(myTEHandle);
- TEDispose(myTEHandle);
- }
- Last_Type = noMode; /* ... in case we return early. */
-
- // Show or Hide the Next & Previous Buttons:
- if ( (topics[Current_Topic].resource_end -
- topics[Current_Topic].resource_start) >= 1) {
- GetDItem(helpPtr, Next_Button, &bType, &bHandle, &bBox);
- ShowControl((ControlHandle)bHandle);
- GetDItem(helpPtr, Prev_Button, &bType, &bHandle, &bBox);
- ShowControl((ControlHandle)bHandle);
- }
- else {
- GetDItem(helpPtr, Next_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
- GetDItem(helpPtr, Prev_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
- }
-
- // Compute which picture to display:
- mesg_this_one = thisPict - topics[Current_Topic].resource_start + 1;
- mesg_max_one = topics[Current_Topic].resource_end -
- topics[Current_Topic].resource_start + 1;
-
- newPict = GetPicture(thisPict); /* Display the picture ... */
- if (newPict == nil) {
- if (thisPict == topics[Initial_Picture].resource_start)
- H_Error_Message(err_intro_pict);
- else
- H_Error_Message(err_no_pict);
- return;
- }
-
- InvalRect(&Display_Rect);
- /* ... so H_HandleUpdate() can take care of this:
- pBox = Display_Rect;
- EraseRect(&pBox);
- pictRect = (**newPict).picFrame;
- CenterRects(&pictRect, &pBox);
- oldClip = NewRgn();
- GetClip(oldClip);
- ClipRect(&pBox);
- DrawPicture(newPict, &pictRect);
- SetClip(oldClip);
- DisposeRgn(oldClip);
- */
-
- if (thisPict == topics[Initial_Picture].resource_start)
- H_User_Message("\pStatus: <Intro PICTure>");
- else {
- NumToString(mesg_this_one, s1);
- NumToString(mesg_max_one, s2);
- pStrCat("\pStatus: Screen ", s1, s3);
- pStrCat(s3, "\p of ", s4);
- pStrCat(s4, s2, s5);
- H_User_Message(s5);
- }
-
- Current_Pict = thisPict;
- Last_Type = pict;
-
- } /* H_Display_Pict */
-
-
-
- void H_Display_Text (void) {
-
- PicHandle thePict;
- short bType, excess;
- Handle bHandle;
- Rect bBox;
-
-
- if (Last_Type == pict) {
- thePict = GetPicture(Current_Pict);
- if (thePict != nil) ReleaseResource(thePict);
- }
- else if (Last_Type == text) {
- if (newStyle) {
- HUnlock(myStylHandle);
- ReleaseResource(myStylHandle);
- }
- HUnlock(myTextHandle);
- ReleaseResource(myTextHandle);
- DisposeControl(hScrollBar);
- HUnlock(myTEHandle);
- TEDispose(myTEHandle);
- }
- Last_Type = noMode;
-
- myTextHandle = GetResource('TEXT', topics[Current_Topic].resource_start);
- if (myTextHandle == nil) {
- H_Error_Message(err_no_text);
- return;
- }
- MoveHHi(myTextHandle);
- HLock(myTextHandle);
-
- if (newStyleTE) {
- myStylHandle = GetResource('styl', topics[Current_Topic].resource_start);
- if (myStylHandle != nil) {
- MoveHHi(myStylHandle);
- HLock(myStylHandle);
- }
- }
- newStyle = newStyleTE && (myStylHandle != nil);
-
- // Hide Next & Previous Buttons:
-
- GetDItem(helpPtr, Next_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
- GetDItem(helpPtr, Prev_Button, &bType, &bHandle, &bBox);
- HideControl((ControlHandle)bHandle);
-
- EraseRect(&Display_Rect);
-
- hScrollBar = GetNewControl(Help_Window, helpPtr);
-
- // Frame the text box:
-
- InvalRect(&Frame_Rect);
- /* ... so H_HandleUpdate() can take care of this:
- MoveTo(Frame_Rect.right, Frame_Rect.top);
- LineTo(Frame_Rect.left, Frame_Rect.top);
- LineTo(Frame_Rect.left, Frame_Rect.bottom - frame);
- LineTo(Frame_Rect.right, Frame_Rect.bottom - frame);
- */
-
- // Create & fill-in a Text Edit Handle:
-
- if (newStyle)
- myTEHandle = TEStylNew(&Dest_Rect, &View_Rect); // A new TEHandle.
- else
- myTEHandle = TENew(&Dest_Rect, &View_Rect);
- MoveHHi(myTEHandle);
- HLock(myTEHandle);
- if (newStyle)
- TEStylInsert(*myTextHandle, SizeResource(myTextHandle),
- (StScrpHandle) myStylHandle, myTEHandle);
- else
- TEInsert(*myTextHandle, SizeResource(myTextHandle), myTEHandle);
- // TEUpdate(&View_Rect, myTEHandle); -- in H_HandleUpdate()
- H_User_Message("\pStatus: <Text Mode>");
-
- // Set-up scrolling parameters:
-
- if (newStyle)
- excess = TEGetHeight((*myTEHandle)->nLines, 1, myTEHandle) -
- (View_Rect.bottom - View_Rect.top);
- else
- excess = ((*myTEHandle)->nLines * (*myTEHandle)->lineHeight) -
- (View_Rect.bottom - View_Rect.top);
-
- if (excess > 0) {
- SetCtlMax(hScrollBar, excess);
- // HiliteControl(hScrollBar, ON); -- contrlMax > 0 does this.
- maxTopLine = GetLineNbr(newStyle, myTEHandle, excess);
- }
- else {
- SetCtlMax(hScrollBar, 0);
- // HiliteControl(hScrollBar, OFF); -- zip contrlMax does this !!
- // maxTopLine = 1; -- doesn't matter because Scroll Bar is inactive.
- }
-
- currentTopLine = 1; /* Begin at the begin. */
- halfPageTopLine = GetLineNbr(newStyle, myTEHandle, halfPagePix);
-
- Last_Type = text;
-
- } /* H_Display_Text */
-
-
-
- void H_Error_Message (ErrorTypes theError) {
-
- short bType;
- Handle bHandle;
- Rect bBox;
- DialogPtr alert;
- GrafPtr savePort;
- short whatHit;
-
-
- alert = GetNewDialog(Help_Error, nil, (WindowPtr)-1);
- ;
- GetDItem(alert, ((DialogPeek)alert)->aDefItem, &bType, &bHandle, &bBox);
- InsetRect(&bBox, -6, -6);
- SetDItem (alert,
- ((DialogPeek)alert)->aDefItem + 1, // = my user item.
- userItem,
- (Handle)&H_Frame_Alert_Button,
- &bBox);
- ;
- SetPort(alert);
- DisplayWindow(alert, true);
- ClipRect(&alert->portRect);
- SysBeep(10);
-
- switch (theError) {
- case err_no_HTBL:
- H_Dialog_String(alert, 4, "\pNo HTBL (Help Table resource)");
- H_Dialog_String(alert, 5, "\pwas found in your resource fork!!");
- H_Dialog_String(alert, 6, "\pPlease create one immediately.");
- break;
-
- case err_min_res:
- H_Dialog_String(alert, 4, "\pYou should have at least an intro");
- H_Dialog_String(alert, 5, "\pscreen and one Help screen for your");
- H_Dialog_String(alert, 6, "\pHelp system.");
- break;
-
- case err_intro_pict:
- H_Dialog_String(alert, 4, "\pThis program assumes that the intro");
- H_Dialog_String(alert, 5, "\pscreen is always a picture!!");
- H_Dialog_String(alert, 6, "\pPlease change the screen.");
- break;
-
- case err_bad_type:
- H_Dialog_String(alert, 4, "\pScreen types are either PICT or");
- H_Dialog_String(alert, 5, "\pTEXT. One of your HTBL fields for");
- H_Dialog_String(alert, 6, "\pscreen types is incorrect.");
- break;
-
- case err_no_pict:
- H_Dialog_String(alert, 4, "\pThe PICT(s) for this topic do not");
- H_Dialog_String(alert, 5, "\pexist?? Very UNcool!! I will exit");
- H_Dialog_String(alert, 6, "\pto the Finder rather than crash ...");
- break;
-
- case err_no_text:
- H_Dialog_String(alert, 4, "\pThe TEXT for this topic does not");
- H_Dialog_String(alert, 5, "\pexist?? Very UNcool!! I will exit");
- H_Dialog_String(alert, 6, "\pto the Finder rather than crash ...");
- break;
-
- default: break;
-
- } /* end switch */
-
- ModalDialog((ProcPtr)&H_Modal_Filter, &whatHit);
- DisposDialog(alert);
-
- if (hHTBL != nil) {
- /* Not gone, for example, if err_intro_pict which
- ** would cause a premature exit from Init_Help() */
- HUnlock(hHTBL);
- ReleaseResource(hHTBL);
- }
-
- DoQuit();
-
- } /* H_Error_Message */
-
-
-
- void H_Handle_List_Event (short whatHit) {
-
-
- // Because the listed topics[] start at index = 1.
- // The Intro screen, a PICT, has an index = 0:
- Current_Topic = whatHit + 1;
-
- H_Set_Button_State(Prev_Button, false);
-
- if (topics[Current_Topic].resource_end - topics[Current_Topic].resource_start)
- H_Set_Button_State(Next_Button, true);
- else H_Set_Button_State(Next_Button, false);
-
- if (topics[Current_Topic].screen_mode == pict)
- H_Display_Pict(topics[Current_Topic].resource_start);
- else if (topics[Current_Topic].screen_mode == text)
- H_Display_Text();
- else
- SysBeep(10);
-
- } /* H_Handle_List_Event */
-
-
-
- void H_Handle_Update (void) {
-
- short pType;
- Handle pHandle;
- Rect pBox, pictRect;
- PicHandle thePict;
- RgnHandle oldClip;
- RGBColor foreColor;
- AuxCtlHandle acHndl;
- CCTabHandle ccTable;
-
-
- // if (helpPtr == nil) return; -- routine NOT called if so.
-
- // SetPort(helpPtr); -- already set in main HandleUpdate()
-
- H_Refresh_Topics();
- FrameDefaultButton(helpPtr);
-
- if (topics[Current_Topic].screen_mode == text) {
- if (gMac2) {
- GetForeColor(&foreColor);
- if (GetAuxCtl(hScrollBar, &acHndl)) {
- ccTable = (**acHndl).acCTable;
- RGBForeColor(& ((**ccTable).ctTable)[cFrameColor].rgb );
- }
- } /* gMac2 */
- ;
- // Three sides of the frame:
- MoveTo(Frame_Rect.right, Frame_Rect.top);
- LineTo(Frame_Rect.left, Frame_Rect.top);
- /* _LineTo draws on OUTSIDE of point: */
- LineTo(Frame_Rect.left, Frame_Rect.bottom - frame);
- LineTo(Frame_Rect.right, Frame_Rect.bottom - frame);
- ;
- if (gMac2) RGBForeColor(&foreColor);
-
- TEUpdate(&View_Rect, myTEHandle);
- } /* text item */
-
- else if (topics[Current_Topic].screen_mode == pict) {
- thePict = GetPicture(Current_Pict);
- if (thePict == nil) SysBeep(10);
- else {
- pBox = Display_Rect;
- EraseRect(&pBox);
- pictRect = (**thePict).picFrame;
- CenterRects(&pictRect, &pBox);
- oldClip = NewRgn();
- GetClip(oldClip);
- ClipRect(&pBox);
- DrawPicture(thePict, &pictRect);
- SetClip(oldClip);
- DisposeRgn(oldClip);
- } /* Got a picture */
- } /* pict item */
-
- DrawDialog(helpPtr);
-
- } /* H_Handle_Update */
-
-
-
- void Init_Help (void) {
-
- char *HTBL_mastPtr;
- short index;
- long mode;
- char ch;
-
-
- /* Haven't called Create_Help() yet. Placed at
- ** start of routine just in case we die early !! */
- helpPtr = nil;
- Last_Type = noMode;
-
- hHTBL = (HelpInfoHdl)GetResource('HTBL', HTBL_RSRC);
- if (hHTBL == nil) {
- H_Error_Message(err_no_HTBL);
- return;
- }
- MoveHHi(hHTBL);
- HLock(hHTBL);
-
- HTBL_mastPtr = (char*) *hHTBL;
- First_Menu = Parse_Int((varedPtr) &HTBL_mastPtr);
- Last_Menu = Parse_Int((varedPtr) &HTBL_mastPtr);
- START = Initial_Picture;
- FINISH = Parse_Int((varedPtr) &HTBL_mastPtr); /* Zero-based count */
-
- // Enough Help screens to proceed ??? Must have at least 2:
- if (FINISH < 1) {
- H_Error_Message(err_min_res);
- return;
- }
- if (FINISH > MAX_TOPICS -1) FINISH = MAX_TOPICS - 1;
-
- // Now, loop through all the screens:
- for (index = START; index <= FINISH; index++)
- {
- mode = Parse_OSType((varedPtr) &HTBL_mastPtr);
- ch = (char)(mode >> 24);
- if ((ch == 'p') || (ch == 'P'))
- topics[index].screen_mode = pict;
- else if ((ch == 't') || (ch == 'T'))
- topics[index].screen_mode = text;
- else {
- H_Error_Message(err_bad_type);
- return;
- }
-
- if ((index == START) && (topics[index].screen_mode != pict)) {
- H_Error_Message(err_intro_pict);
- return;
- }
-
- // Get resource bounds:
- topics[index].resource_start = Parse_Int((varedPtr) &HTBL_mastPtr);
- topics[index].resource_end = Parse_Int((varedPtr) &HTBL_mastPtr);
-
- Parse_String ( (char*)topics[index].topic_name, (varedPtr) &HTBL_mastPtr );
- }
-
- /* All we really needed to do here was fill in our topics[]
- array so we can immediately dispose of our Handle. */
- HUnlock(hHTBL);
- ReleaseResource(hHTBL);
- hHTBL = nil; /* Mark as gone !! See H_Error_Message */
-
- // Now, fill in our dynamic balloon array:
-
- for (index = OK_Button;
- index <= Message_Area * 2 /* 2 strings per DLOG item */;
- index++) {
- gDynamicBalloons[index].dynamicStrID = Help_Window;
- gDynamicBalloons[index].dynamicStrIndex = index;
- }
-
- index = OK_Button;
- SetRect(&gDynamicBalloons[index].dynamicR, 352, 260, 412, 280);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Topics_Area - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 305, 32, 465, 185);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Display_Area - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 10, 10, 290, 290);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Next_Button - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 405, 225, 465, 245);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Prev_Button - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 305, 225, 385, 245);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Mast_Head - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 305, 10, 465, 27);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- index = (Message_Area - 1)*2 + 1;
- SetRect(&gDynamicBalloons[index].dynamicR, 305, 195, 465, 215);
- gDynamicBalloons[index + 1].dynamicR = gDynamicBalloons[index].dynamicR;
-
- newStyleTE = StylizedTE(); // Whoops ... almost forgot !!
-
- } /* Init_Help */
-
-
-
- void Kill_Help_Window (void) {
-
- PicHandle thePict;
-
-
- if (helpPtr == nil) return;
-
- if (Last_Type == pict) {
- thePict = GetPicture(Current_Pict);
- if (thePict != nil) ReleaseResource(thePict);
- }
- else if (Last_Type == text) {
- if (newStyle) {
- HUnlock(myStylHandle);
- ReleaseResource(myStylHandle);
- }
- HUnlock(myTextHandle);
- ReleaseResource(myTextHandle);
- DisposeControl(hScrollBar);
- HUnlock(myTEHandle);
- TEDispose(myTEHandle);
- }
- Last_Type = noMode;
-
- LDispose(my_List_Handle);
-
- THideWindow(helpPtr);
- DisposDialog(helpPtr);
- helpPtr = nil; /* Mark as gone. */
-
- } /* Kill_Help_Window */
-
-
-
- pascal void H_Scroll_Filter (ControlHandle ctl, short thePart) {
-
- short min, max; // ScrollBar's min & max values.
- short newValue, oldValue, linePix;
- long finalTicks;
-
-
- min = (*hScrollBar)->contrlMin;
- max = (*hScrollBar)->contrlMax;
- oldValue = GetCtlValue(hScrollBar);
- newValue = oldValue;
-
- linePix = GetLineHeight(newStyle, myTEHandle, currentTopLine);
-
- switch (thePart) {
-
- case inUpButton:
- newValue -= linePix;
- if (newValue < min) {
- newValue = min;
- currentTopLine = 1;
- }
- else --currentTopLine;
- break;
-
- case inDownButton:
- newValue += linePix;
- if (newValue > max) {
- newValue = max;
- currentTopLine = maxTopLine;
- }
- else currentTopLine++;
- break;
-
- case inPageUp:
- newValue -= halfPagePix;
- if (newValue < min) {
- newValue = min;
- currentTopLine = 1;
- }
- else currentTopLine -= halfPageTopLine;
- break;
-
- case inPageDown:
- newValue += halfPagePix;
- if (newValue > max) {
- newValue = max;
- currentTopLine = maxTopLine;
- }
- else currentTopLine += halfPageTopLine;
- break;
-
- default: break;
-
- } /* end switch */
-
- if (newValue != oldValue) { /* Avoid blinking Thumb. */
- SetCtlValue(hScrollBar, newValue);
- Delay(2, &finalTicks);
- H_Scroll_Text(oldValue, newValue);
- }
-
- } /* H_Scroll_Filter */
-
-
-
- short Parse_Int (varedPtr addrMPtr) {
-
- short result = 0;
- unsigned char hiByte, loByte;
-
-
- hiByte = (unsigned char) *( (*addrMPtr)++ ); // Increment the Master Pointer.
- loByte = (unsigned char) *( (*addrMPtr)++ );
-
- result = result | hiByte;
- result = (result << 8) | loByte;
-
- return (result);
-
- } /* Parse_Int */
-
-
-
- long Parse_OSType (varedPtr addrMPtr) {
-
- long result = 0;
- char nextByte;
- short index;
-
-
- // Loop through 4 bytes:
- for (index = 1; index <= sizeof(long); index++) {
- nextByte = *( (*addrMPtr)++ );
- result = (result << 8) | (long) nextByte;
- }
-
- return (result);
-
- } /* Parse_OSType */
-
-
- void Parse_String (char *destStr, varedPtr addrSrcStrPtr) {
-
- short len = *destStr++ = *( (*addrSrcStrPtr)++ );
- Boolean wordAlign = ((len % 2) == 0);
-
- while (--len >= 0) *destStr++ = *((*addrSrcStrPtr)++);
- if (wordAlign) (*addrSrcStrPtr)++;
-
- } /* Parse_String */
-
-
-
- void H_Refresh_Topics (void) {
-
- Rect tempRect;
- PenState pnState;
- RgnHandle oldClip;
-
-
- LUpdate(helpPtr->visRgn, my_List_Handle);
- tempRect = List_Rect;
- InsetRect(&tempRect, -frame, -frame);
- FrameRect(&tempRect);
-
- H_DrawGrowIcon(my_List_Handle);
-
- } /* H_Refresh_Topics */
-
-
-
- void H_Scroll_Picture (short whatHit) {
-
- short theMax, theMin;
-
-
- theMin = topics[Current_Topic].resource_start;
- theMax = topics[Current_Topic].resource_end;
-
- if ((whatHit == Next_Button) && (Current_Pict < theMax)) {
- Current_Pict++;
- H_Set_Button_State(Prev_Button, true);
- if (Current_Pict < theMax) H_Set_Button_State(Next_Button, true);
- else H_Set_Button_State(Next_Button, false);
- H_Display_Pict(Current_Pict);
- }
- else if ((whatHit == Prev_Button) && (Current_Pict > theMin)) {
- --Current_Pict;
- H_Set_Button_State(Next_Button, true);
- if (Current_Pict > theMin) H_Set_Button_State(Prev_Button, true);
- else H_Set_Button_State(Prev_Button, false);
- H_Display_Pict(Current_Pict);
- }
- else SysBeep(10);
-
- } /* H_Scroll_Picture */
-
-
-
- void H_Scroll_Text (short oldValue, short newValue) {
-
-
- TEScroll(0, (oldValue - newValue), myTEHandle);
-
- } /* H_Scroll_Text */
-
-
-
- void H_Set_Button_State (int itemNum, Boolean state) {
-
- short bType;
- Handle bHandle;
- Rect bBox;
-
-
- GetDItem(helpPtr, itemNum, &bType, &bHandle, &bBox);
- if (state) HiliteControl((ControlHandle)bHandle, ON);
- else HiliteControl((ControlHandle)bHandle, OFF);
-
- } /* H_Set_Button_State */
-
-
-
- void H_User_Message (Str255 theStr) {
-
- short mType;
- Handle mHandle;
- Rect mBox;
-
-
- GetDItem(helpPtr, Message_Area, &mType, &mHandle, &mBox);
- SetIText(mHandle, theStr);
- // DrawDialog(helpPtr); -- SetIText() draws the text.
- ValidRect(&mBox);
-
- } /* H_User_Message */
-
-
-
- pascal Boolean H_Modal_Filter (DialogPtr dlg, EventRecord *event, short *itemHit) {
-
- Boolean letModalContinueToHandleIt = false, /* Reverse logic */
- noFurtherProcessing = true,
- result;
- ControlHandle okButton;
- char key;
-
-
- switch (event->what) {
-
- case keyDown:
- key = event->message & charCodeMask;
- if ( (key == '\r') || (key == Enter) ) {
- okButton = GetDefaultButton(dlg);
- SimulateClick(okButton);
- result = noFurtherProcessing;
- *itemHit = ok;
- }
- else {
- SysBeep(10);
- result = letModalContinueToHandleIt;
- }
- break;
-
- default:
- result = letModalContinueToHandleIt;
-
- } /* end switch */
-
- return (result);
-
- } /* H_Modal_Filter */
-
-
-
- pascal void H_Frame_Alert_Button (DialogPtr dlg, short theItem) {
-
-
- FrameDefaultButton (dlg);
-
- } /* H_Frame_Alert_Button */
-
-
-
- void H_DrawGrowIcon (ListHandle theList) {
- /* Special routine because the list is INSIDE of another window. */
-
- PenState pnState;
- RgnHandle oldClip;
- Boolean listHasGrowIcon;
- Rect listGrowRect, tempRect;
- ControlHandle listScrollBar;
- RGBColor foreColor;
- AuxCtlHandle acHndl;
- CCTabHandle ccTable;
-
-
- listHasGrowIcon = (Boolean) LoWord( (*theList)->refCon );
- if (!listHasGrowIcon) return;
-
- listGrowRect = (*theList)->rView;
- listGrowRect.left = listGrowRect.right + frame;
- listGrowRect.right = listGrowRect.right + growBoxSize;
- listGrowRect.top = listGrowRect.bottom + frame;
- listGrowRect.bottom = listGrowRect.bottom + growBoxSize;
-
- if ( (**theList).lActive ) {
- GetPenState(&pnState);
- oldClip = NewRgn();
- GetClip(oldClip);
- ;
- PenNormal();
- PenSize(frame, frame);
- PenPat(&gray);
- ClipRect(&List_Rect);
-
- if (gMac2) {
- GetForeColor(&foreColor);
-
- if ((**theList).vScroll != nil)
- listScrollBar = (**theList).vScroll;
- else if ((**theList).hScroll != nil)
- listScrollBar = (**theList).hScroll;
- else
- listScrollBar = nil;
-
- if ((listScrollBar != nil) && GetAuxCtl(listScrollBar, &acHndl)) {
- ccTable = (**acHndl).acCTable;
- RGBForeColor(& ((**ccTable).ctTable)[cFrameColor].rgb );
- }
- } /* gMac2 */
-
- // First the bigger rect at the bottom-right ...
- tempRect = listGrowRect;
- tempRect.top = tempRect.top + 5;
- tempRect.left = tempRect.left + 5;
- tempRect.right = tempRect.right - 2;
- tempRect.bottom = tempRect.bottom - 2;
- FrameRect(&tempRect);
-
- // Then the small rect at the topLeft ...
- tempRect = listGrowRect;
- tempRect.top = tempRect.top + 3;
- tempRect.left = tempRect.left + 3;
- tempRect.right = tempRect.left + 5;
- tempRect.bottom = tempRect.top + 5;
- EraseRect(&tempRect);
- FrameRect(&tempRect);
-
- if (gMac2) RGBForeColor(&foreColor);
- ;
- SetClip(oldClip);
- SetPenState(&pnState);
- }
- else /* List NOT active */ EraseRect(&listGrowRect);
-
- } /* H_DrawGrowIcon */
-
-
-
- long H_GetListScrollValues (ListHandle theList) {
- /* Returns value of vertical Scroll Bar in High word
- ** and value of horizontal Scroll Bar in low word.
- ** A non-existent or inactive Scroll Bar returns a
- ** value = -1 in the appropriate word. */
-
- long high = 0x0000FFFF, low = 0x0000FFFF;
- ControlHandle vS, hS;
-
-
- vS = (*theList)->vScroll;
- hS = (*theList)->hScroll;
-
- if ( (vS != nil) && ((**vS).contrlMax > (**vS).contrlMin) )
- high = (long) GetCtlValue(vS);
-
- if ( (hS != nil) && ((**hS).contrlMax > (**hS).contrlMin) )
- low = (long) GetCtlValue(hS);
-
- return ( (high << 16) | low );
-
- } /* H_GetListScrollValues */
-
-
-
-
- /* { end file "about.c" } */
-